package com.baselibrary.manager

import com.baselibrary.Constants.*
import com.baselibrary.router.ActivityRouter
import com.baselibrary.utils.SpUtils
import com.baselibrary.utils.TextColorGradientUtils
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI
import com.sensorsdata.analytics.android.sdk.SensorsDataDynamicSuperProperties
import org.json.JSONException
import org.json.JSONObject

class SensorsDataManager {

    companion object {
        private val TAG = "SensorsDataManager"
        private var mCreateTimeMillis: Long = 0
        private var mDestroyTimeMillis: Long = 0
        private var mInstance: SensorsDataManager? = null

        //页面来源 ：动态、话题、讲坛分类、讲坛、视频、专栏、文章、百科
        var formPagePos = ""

        //分享方式 ：微信好友、朋友圈、分享海报
        private var shareWay = ""

        //发现、广场、商城
        private var homePagePos = "发现"

        //附近酒窖列表、全屏大地图、搜索结果页
        private var wineryPagePos = "附近酒窖列表"
        private var wineryCommentPagePos = "酒窖详情页"

        //酒窖详情页、用户主页、社区发现页
        private var wineryDynamicPagePos = "酒窖详情页"
        private var wineryName = ""
        val instance: SensorsDataManager
            @Synchronized get() {
                if (mInstance == null) {
                    synchronized(SensorsDataManager::class.java) {
                        if (mInstance == null) {
                            mInstance = SensorsDataManager()
                        }
                    }
                }
                return mInstance!!
            }
    }



    //公共属性
    fun setPuiblicProperties() {
        SensorsDataAPI.sharedInstance().registerDynamicSuperProperties(SensorsDataDynamicSuperProperties {
            try {
                // 比如 isLogin() 是用于获取用户当前的登录状态，SDK 会自动获取 getDynamicSuperProperties 中的属性添加到触发的事件中。
                return@SensorsDataDynamicSuperProperties JSONObject().put("is_login", SpUtils.getInstance().isLogin)
            } catch (e: Exception) {
                e.printStackTrace()
            }
            null
        })
    }

    /**
     * 记录激活事件
     */
    fun trackInstallation() {
        try {
            // 触发激活事件
            SensorsDataAPI.sharedInstance().trackAppInstall()
        } catch (e: Exception) {
            e.printStackTrace()
        }

    }

    //选择规格页点击立即购买按钮时触发
    fun nowBuy(commodity_id: String, commodity_name: String, commodity_specification: String, pick_up_way: String, marketing_classification: String, commodity_classification: String, commodity_present_price: Double?, commodity_quantity: Int) {
        try {
            val properties = JSONObject()
            /*            commodity_id	商品ID
            commodity_name	商品名称
            commodity_specification	商品规格
            pick_up_way	提货方式
            marketing_classification	营销分类
            commodity_classification	商品分类
            commodity_present_price	商品现价
            commodity_quantity	商品数量*/
            properties.put("commodity_id", commodity_id)
            properties.put("commodity_name", commodity_name)
            properties.put("commodity_specification", commodity_specification)
            properties.put("pick_up_way", pick_up_way)
            properties.put("marketing_classification", marketing_classification)
            properties.put("commodity_classification", commodity_classification)
            properties.put("commodity_present_price", commodity_present_price)
            properties.put("commodity_quantity", commodity_quantity)
            SensorsDataAPI.sharedInstance().track("SelectSpecificationsPagebuyNowclick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }

    }

    //    商品曝光
    fun goodsShow(exposure_type: String, commodity_location: Int, commodity_id: String, commodity_name: String, commodity_specification: String, marketing_classification: String, commodity_classification: String, commodity_present_price: Double) {
        try {
            val properties = JSONObject()
            /*$预置属性
            exposure_type	曝光类型	STRING	商品列表页、活动页面、分享页面曝光
            commodity_location	商品所在位置序号	NUMBER	1、2、3、4
            commodity_id	商品ID	STRING
            commodity_name	商品名称	STRING	酣客酱酒经典mino人脸瓶
            commodity_specification	商品规格	STRING	500ml、尺码、s
            marketing_classification	营销分类	STRING	指前端分类：即全部商品、酣客酱酒、酣客原创、粉丝福利、酒类器皿
            commodity_classification	商品分类	STRING	业务维度的商品分类
            commodity_present_price	商品现价	NUMBER	2299*/
            properties.put("exposure_type", exposure_type)
            properties.put("commodity_location", commodity_location)
            properties.put("commodity_id", commodity_id)
            properties.put("commodity_name", commodity_name)
            properties.put("commodity_specification", commodity_specification)
            properties.put("marketing_classification", marketing_classification)
            properties.put("commodity_classification", commodity_classification)
            properties.put("commodity_present_price", commodity_present_price)
            SensorsDataAPI.sharedInstance().track("CommodityExposure", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }

    }

    // 浏览商品详情页
    fun goodsDetails(commodity_id: String, commodity_name: String, commodity_specification: String, marketing_classification: String, commodity_classification: String, commodity_present_price: Double) {
        try {
            val properties = JSONObject()
            /*commodity_id	商品ID	STRING
            commodity_name	商品名称	STRING	酣客酱酒经典mino人脸瓶
            commodity_specification	商品规格	STRING	500ml、尺码、s
            marketing_classification	营销分类	STRING	指前端分类：即全部商品、酣客酱酒、酣客原创、粉丝福利、酒类器皿
            commodity_classification	商品分类	STRING	业务维度的商品分类
            commodity_present_price	商品现价	NUMBER	2299*/
            properties.put("commodity_id", commodity_id)
            properties.put("commodity_name", commodity_name)
            properties.put("commodity_specification", commodity_specification)
            properties.put("marketing_classification", marketing_classification)
            properties.put("commodity_classification", commodity_classification)
            properties.put("commodity_present_price", commodity_present_price)
            SensorsDataAPI.sharedInstance().track("CommodityDetail", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }

    }

    // 商品详情页立即购买点击
    fun commodityDetailBuyNowClick(commodity_id: String, commodity_name: String, commodity_specification: String, marketing_classification: String, commodity_classification: String, pick_up_way: String, commodity_quantity: Int, commodity_present_price: Double) {
        try {
            val properties = JSONObject()
            /*commodity_id	商品ID	STRING
            commodity_name	商品名称	STRING	酣客酱酒经典mino人脸瓶
            commodity_specification	商品规格	STRING	500ml、尺码、s
            pick_up_way	提货方式	STRING	邮寄、机构提货
            marketing_classification	营销分类	STRING	指前端分类：即全部商品、酣客酱酒、酣客原创、粉丝福利、酒类器皿
            commodity_classification	商品分类	STRING	业务维度的商品分类
            commodity_present_price	商品现价	NUMBER	2299
            commodity_quantity	商品数量	NUMBER	1、2、3*/
            properties.put("commodity_id", commodity_id)
            properties.put("commodity_name", commodity_name)
            properties.put("commodity_specification", commodity_specification)
            properties.put("marketing_classification", marketing_classification)
            properties.put("commodity_classification", commodity_classification)
            properties.put("commodity_present_price", commodity_present_price)
            properties.put("commodity_quantity", commodity_quantity)
            properties.put("pick_up_way", pick_up_way)
            SensorsDataAPI.sharedInstance().track("CommodityDetailbuyNowclick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }

    }

    // 商品详情页立即购买点击
    fun addToShoppingCart(commodity_id: String, commodity_name: String, commodity_specification: String, marketing_classification: String, commodity_classification: String, pick_up_way: String, commodity_quantity: Int, commodity_present_price: Double) {
        try {
            val properties = JSONObject()
            /*commodity_id	商品ID	STRING
            commodity_name	商品名称	STRING	酣客酱酒经典mino人脸瓶
            commodity_specification	商品规格	STRING	500ml、尺码、s
            pick_up_way	提货方式	STRING	邮寄、机构提货
            marketing_classification	营销分类	STRING	指前端分类：即全部商品、酣客酱酒、酣客原创、粉丝福利、酒类器皿
            commodity_classification	商品分类	STRING	业务维度的商品分类
            commodity_present_price	商品现价	NUMBER	2299
            commodity_quantity	商品数量	NUMBER	1、2、3*/
            properties.put("commodity_id", commodity_id)
            properties.put("commodity_name", commodity_name)
            properties.put("commodity_specification", commodity_specification)
            properties.put("marketing_classification", marketing_classification)
            properties.put("commodity_classification", commodity_classification)
            properties.put("commodity_present_price", commodity_present_price)
            properties.put("commodity_quantity", commodity_quantity)
            properties.put("pick_up_way", pick_up_way)
            SensorsDataAPI.sharedInstance().track("AddToShoppingCart", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }

    }


    //添加收获地址页面浏览
    fun addAddressLook() {
        try {
            SensorsDataAPI.sharedInstance().track("AddedHarvestAddressPageBrowsing")
        } catch (e: Exception) {
            e.printStackTrace()
        }

    }

    //添加新地址点击
    fun addNewAddress() {
        try {
            SensorsDataAPI.sharedInstance().track("AddNewAddressClick")
        } catch (e: Exception) {
            e.printStackTrace()
        }

    }

    //咨询点击
    fun counsel() {
        try {
            SensorsDataAPI.sharedInstance().track("ConsultingClick")
        } catch (e: Exception) {
            e.printStackTrace()
        }

    }

    //访问商城
    fun browseShoppingMall() {
        try {
            SensorsDataAPI.sharedInstance().track("AccessMall")
        } catch (e: Exception) {
            e.printStackTrace()
        }

    }

    //选择提货方式
    fun selectDeliveryWay() {
        try {
            SensorsDataAPI.sharedInstance().track("SelectDeliveryWay")
        } catch (e: Exception) {
            e.printStackTrace()
        }

    }

    //浏览注册、登录页面
    fun lookLoginPage() {
        try {
            SensorsDataAPI.sharedInstance().track("LoginPageView")
        } catch (e: Exception) {
            e.printStackTrace()
        }

    }


    //点击登录按钮   苹果帐号授权、微信登录、本机一键登录、帐号密码、验证码登录 、随便逛逛
    fun loginType(type: Int) {
        var typeStr = ""
        try {
            val properties = JSONObject()
            when (type) {
                0 -> typeStr = "本机号一键登录"
                1 -> typeStr = "手机号验证码登录"
                2 -> typeStr = "账号密码登录"
                3 -> typeStr = "微信授权后登录"
                4 -> typeStr = "随便逛逛"
            }
            properties.put("login_type", typeStr)
            SensorsDataAPI.sharedInstance().track("LoginClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }

    }

    //点击获取验证码按钮
    fun getCode(phoneNum: String) {
        try {
            val properties = JSONObject()
            properties.put("phone_number", TextColorGradientUtils.phoneStarFormat(phoneNum))//手机号脱敏处理
            SensorsDataAPI.sharedInstance().track("GetCode", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //点击未读消息时候触发
    fun messageReminder(typeStr: String) {
        try {
            val properties = JSONObject()
            //赞和收藏、评论我的、新增粉丝、在线客服、好友聊天、系统消息
            properties.put("messageReminder_type", typeStr)
            SensorsDataAPI.sharedInstance().track("MessageReminder", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //点击时候触发
    fun brookPageElementClick(typeStr: String) {
        try {
            val properties = JSONObject()
            //赞和收藏、评论我的、新增粉丝、系统消息、系统消息详情列表、在线客服、用户聊天、创建聊天、底部TAB
            properties.put("brookberpage_click_name", typeStr)
            SensorsDataAPI.sharedInstance().track("BrookPageElementClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //我的好友页\聊天
    fun friendsPageChat() {
        try {
            SensorsDataAPI.sharedInstance().track("FriendsPageChat")
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    //我的粉丝页\回粉统计
    fun fansPageAttention() {
        try {
            SensorsDataAPI.sharedInstance().track("FansPageAttention")
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    //广场页面专栏刷新点击
    fun squareColumnRefreshClick() {
        try {
            SensorsDataAPI.sharedInstance().track("SquareColumnRefreshClick")
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    //评论我的页面快捷交互
    fun commentMeQuick(title: String, isClickLike: Boolean) {
        try {
            val properties = JSONObject()
            properties.put("commentmequick_name", title)
            properties.put("commentmequick_type", if (isClickLike) "快捷点赞" else "快捷回复")
            SensorsDataAPI.sharedInstance().track("CommentMeQuick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //用户访问页面时长  触发 消息中心、赞和收藏、评论我的、我的好友、我的关注、我的粉丝、系统消息列表页、系统消息详情页、在线客服、好友聊天页、好友举报页
    fun brookPageView(name: String) {
        try {
            val properties = JSONObject()
            properties.put("brookpage_view_name", name)
            properties.put("brookpage_view_time", getBrowseTime())
            SensorsDataAPI.sharedInstance().track("BrookPageView", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //社区页重点页面浏览
    fun communityEmphasisPageView(name: String) {
        try {
            val properties = JSONObject()
            properties.put("page_name", name)
            properties.put("page_view_time", getBrowseTime())
            SensorsDataAPI.sharedInstance().track("CommunityEmphasisPageView", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //浏览话题页面
    fun browseTopicPage(topicClass: String, topicSource: String, topicName: String, topicHotProgress: Double, topicNewProgress: Double) {
        try {
            val properties = JSONObject()
            properties.put("topic_class", topicClass)
            properties.put("access_source", topicSource)
            properties.put("topic_name", topicName)
            properties.put("topic_view_time", getBrowseTime())
            properties.put("topic_hot_view_progress", topicHotProgress)
            properties.put("topic_new_view_progress", topicNewProgress)
            SensorsDataAPI.sharedInstance().track("BrowseTopicPage", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //浏览动态页面
    fun browseDynamic(topicClass: String, topicSource: String, dynamicName: String, dynamicTopType: String, dynamicStateType: String, toicName: String, progress: Long) {
        try {
            val properties = JSONObject()
            properties.put("topic_class", topicClass)
            properties.put("access_source", topicSource)
            properties.put("dynamic_name", dynamicName)
            properties.put("dynamic_top_type", dynamicTopType)
            properties.put("dynamic_state_type", dynamicStateType)
            properties.put("dynamic_view_time", getBrowseTime())
            properties.put("topic_name", toicName)
            properties.put("video_playback_progress", progress)
            SensorsDataAPI.sharedInstance().track("BrowseDynamic", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //动态点赞
    fun giveLike(hasGive: Boolean, likePageType: String, likeAddress: String, likeContent: String) {
        try {
            if (!hasGive) {
                val properties = JSONObject()
                properties.put("like_position_type", "动态")
                properties.put("like_page_type", likePageType)
                properties.put("like_address", likeAddress)
                properties.put("like_content", likeContent)
                SensorsDataAPI.sharedInstance().track("Givelike", properties)
            } else {
                val properties = JSONObject()
                properties.put("no_like_position_type", "动态")
                properties.put("no_like_page_type", likePageType)
                properties.put("no_like_content", likeContent)
                SensorsDataAPI.sharedInstance().track("NoGivelike", properties)
            }
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //预约直播
    fun subscribeLive(hasSubscribe: Boolean, liveName: String) {
        try {
            val properties = JSONObject()
            properties.put("live_name", liveName)
            SensorsDataAPI.sharedInstance().track(if (hasSubscribe) "NoSubscribeLive" else "SubscribeLive", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //登录悬浮弹窗点击
    fun clickLoginTip() {
        try {
            SensorsDataAPI.sharedInstance().track("FloatingLoginWindow")
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //点击Banner
    fun clickBanner(topicName: String, bannerName: String) {
        try {
            val properties = JSONObject()
            properties.put("topic_class", topicName)
            properties.put("rotation_map_name", bannerName)
            SensorsDataAPI.sharedInstance().track("BannerClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //话题内搜索
    fun doSearch(searchAddress: String, searchContent: String) {
        try {
            val properties = JSONObject()
            properties.put("search_address", searchAddress)
            properties.put("search_content", searchContent)
            SensorsDataAPI.sharedInstance().track("SearchOne", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //话题描述点击
    fun clickTopicDes(searchContent: String) {
        try {
            val properties = JSONObject()
            properties.put("topic_name", searchContent)
            SensorsDataAPI.sharedInstance().track("TopicDescriptionClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //最热、最新的点击次数
    fun clickHotAndLatest(searchContent: String) {
        try {
            val properties = JSONObject()
            properties.put("top_new_tab", searchContent)
            SensorsDataAPI.sharedInstance().track("HotNewClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //关注页面——取消静音播放
    fun clickNoVoice(searchContent: String) {
        try {
            val properties = JSONObject()
            properties.put("dynamic_name", searchContent)
            SensorsDataAPI.sharedInstance().track("Unmute", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //扫码点击
    fun clickScan(searchContent: String) {
        try {
            val properties = JSONObject()
            properties.put("scan_code_type", searchContent)
            SensorsDataAPI.sharedInstance().track("ScanCodeClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //个人主页删除动态
    fun clickDeleteDynamic(searchContent: String, releaseTime: String) {
        try {
            val properties = JSONObject()
            properties.put("dynamic_name", searchContent)
            properties.put("Dynamic_release_time", releaseTime)
            SensorsDataAPI.sharedInstance().track("PersonalHomepageDeleteDynamic", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //个人主页内容点击
    fun clickUserPage(content: String) {
        try {
            val properties = JSONObject()
            properties.put("content_name", content)
            SensorsDataAPI.sharedInstance().track("PersonalHomepageContentClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //推荐页广告位点击
    fun clickAd(isTop: Boolean, name: String, columnName: String) {
        try {
            val properties = JSONObject()
            properties.put("article_top_type", if (isTop) "置顶文章" else "非置顶文章")
            properties.put("article_name", name)
            properties.put("special_column_name", columnName)
            SensorsDataAPI.sharedInstance().track("APPHomePageAdvertSpaceClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //推荐页动态点击
    fun clickRecommend(topicClass: String, dynamicName: String, dynamicTopType: String, dynamicStateType: String, toicName: String) {
        try {
            val properties = JSONObject()
            properties.put("topic_class", topicClass)
            properties.put("dynamic_name", dynamicName)
            properties.put("dynamic_top_type", dynamicTopType)
            properties.put("dynamic_state_type", dynamicStateType)
            properties.put("topic_name", toicName)
            SensorsDataAPI.sharedInstance().track("APPHomePageDynamicClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //浏览百科页面
    fun browseBaike(name: String) {
        try {
            val properties = JSONObject()
            properties.put("article_name", name)
            properties.put("article_view_time", getBrowseTime())
            SensorsDataAPI.sharedInstance().track("BrowseBaike", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //个人中心页面浏览
    fun memberPageView() {
        try {
            val properties = JSONObject()
            properties.put("memberpage_view_time", getBrowseTime())
            SensorsDataAPI.sharedInstance().track("MemberPageView", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //首页弹框浏览
    fun homePopupView(name: String, pos: String) {
        try {
            val properties = JSONObject()
            properties.put("home_popup_name", name)
            properties.put("home_popup_position", pos)
            properties.put("home_popup_view_time", getBrowseTime())
            SensorsDataAPI.sharedInstance().track("HomePopupView", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //用户分享时私信好友时触发
    fun privateLetter(fType: String, sType: String) {
        try {
            val properties = JSONObject()
            //动态、话题、讲坛分类、讲坛、视频、专栏、文章、百科
            properties.put("forwarding_type", fType)
            //群发、单发
            properties.put("send_type", sType)
            SensorsDataAPI.sharedInstance().track("PrivateLetter", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //浏览专栏文章页面
    fun browseArticle(type: String, name: String, columnnName: String) {
        try {
            val properties = JSONObject()
            //置顶文章、非置顶文章
            properties.put("article_top_type", type)
            properties.put("article_name", name)
            properties.put("article_view_time", getBrowseTime())
            //专栏名称
            properties.put("special_column_name", columnnName)
            SensorsDataAPI.sharedInstance().track("BrowseArticle", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //点击下载按钮时候触发 type:图片、视频、文档
    fun materialLibraryDownload(name: String, type: String) {
        try {
            val properties = JSONObject()
            properties.put("material_download_name", name)
            properties.put("material_download_type", type)
            SensorsDataAPI.sharedInstance().track("MaterialLibraryDownload", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //分享
    fun forwarding(content: String) {
        try {
            val properties = JSONObject()
            //type:分享：动态、话题、讲坛分类、讲坛、视频、专栏、文章、百科时，触发
            properties.put("forwarding_type", formPagePos)
            //转发方式:APP好友、微信好友、朋友圈、分享海报
            properties.put("forwarding_way", shareWay)
            //分享内容的名称：例如动态名称、话题名称、讲坛分类、讲坛名称、视频名称、专栏名称、文章名称、百科名称
            properties.put("forwarding_content", content)
            SensorsDataAPI.sharedInstance().track("Forwarding", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //用户在文章、百科中点击快捷分享按钮时触发
    fun quickShareClick(type: String, name: String) {
        try {
            val properties = JSONObject()
            //文章、百科
            properties.put("quick_share_type", type)
            properties.put("quick_share_name", name)
            SensorsDataAPI.sharedInstance().track("QuickShareClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //个人中心元素点击
    fun memberPageElementClick(name: String) {
        try {
            val properties = JSONObject()
            //头像、昵称、关注、粉丝、发布、收藏、好友、设置、订单、酒币、直播、手环、粉丝中心、素材库、企业政策、底部TAB“我的”、banner、客服、签到、个人中心banner
            properties.put("memberpageelement_click1", name)
            SensorsDataAPI.sharedInstance().track("MemberPageElementClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //浏览个人主页
    fun browseHomePage(homepageName: String, visitorName: String, browseTime: Long) {
        try {
            val properties = JSONObject()
            properties.put("home_page_name", homepageName)
            properties.put("visitors_name", visitorName)
            properties.put("home_page_view_time", browseTime)
            SensorsDataAPI.sharedInstance().track("BrowseHomePage", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //个人主页内容点击
    fun personalHomepageContentClick(homepageName: String, visitorName: String, contentName: String) {
        try {
            val properties = JSONObject()
            properties.put("homepageName", homepageName)
            properties.put("visitors_name", visitorName)
            properties.put("content_name", contentName)
            SensorsDataAPI.sharedInstance().track("PersonalHomepageContentClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }


    //浏览讲坛分类页面
    fun browseClassForum(name: String, progress: Int) {
        try {
            val properties = JSONObject()
            properties.put("forum_class_name", name)
            properties.put("forum_class_view_time", getBrowseTime())
            properties.put("forum_class_view_progress", progress)
            SensorsDataAPI.sharedInstance().track("BrowseClassForum", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //浏览专栏页面
    fun browseSpecialColumn(name: String, progress: Int) {
        try {
            val properties = JSONObject()
            properties.put("special_column_name", name)
            properties.put("special_column_view_time", getBrowseTime())
            properties.put("special_column_article_view_progress", progress)
            SensorsDataAPI.sharedInstance().track("BrowseSpecialColumn", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //专栏简介点击
    fun specialColumnDescClick(name: String) {
        try {
            val properties = JSONObject()
            properties.put("special_column_name", name)
            SensorsDataAPI.sharedInstance().track("SpecialColumnDescClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //聊天时候触发
    fun chatWithFriends(chatId: String, typeStr: String, otherName: String, isSucc: Boolean, failReason: String = "") {
        try {
            val properties = JSONObject()
            //聊天编号
            properties.put("chatwithfriends_code", chatId)
            //聊天消息类型 文字、图片、视频、图片动态转发、视频动态转发、话题转发、文章转发、直播转发
            properties.put("chatwithfriends_type", typeStr)
            //发起位置 消息列表，好友列表、社区用户主页
            properties.put("chatwithfriends_page", SpUtils.getInstance().getPagePos4Chat())
            //是否发送成功
            properties.put("chatwithfriends_send", isSucc)
            //失败原因 网络原因\未关注\对方未关注
            properties.put("chatwithfriends_fail", failReason)
            //发起的对象  A发起对B的聊天，对象就是B
            properties.put("chatwithfriends_other", otherName)
            SensorsDataAPI.sharedInstance().track("ChatWithFriends", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }


    //分享社区站内内容点击
    fun appFriendsShareClick(title: String, type: Int) {
        try {
            val properties = JSONObject()
            properties.put("appfriendsshareclick_name", title)
            var str = ""
            when (type) {
                DYNAMIC_TYPE_IMG -> str = "图片动态"
                DYNAMIC_TYPE_VIDEO -> str = "视频动态"
                DYNAMIC_TYPE_TOPIC -> str = "话题详情"
                DYNAMIC_TYPE_ARTICLE -> str = "文章详情"
                DYNAMIC_TYPE_LIVE -> str = "直播间详情"
            }
            properties.put("appfriendsshareclick_type", str)
            SensorsDataAPI.sharedInstance().track("AppFriendsShareClick", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //好友聊天页\一键关注
    fun onKeyFollow() {
        try {
            SensorsDataAPI.sharedInstance().track("OneClickAttention")
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    /**
     *素材库\素材查看
     */
    fun materialLook(materialTitle: String, materialType: String, materialTime: Long) {
        val properties = JSONObject()
        properties.put("material_view_name", materialTitle)
        properties.put("material_view_type", materialType)
        properties.put("material_view_duration", materialTime)
        SensorsDataAPI.sharedInstance().track("MaterialLibraryView", properties)
    }

    /**
     *素材库\素材收藏
     */
    fun materialCollection(name: String, materialType: String) {
        val properties = JSONObject()
        properties.put("material_collection_name", name)
        properties.put("material_collection_type", materialType)
        SensorsDataAPI.sharedInstance().track("MaterialLibraryCollection", properties)
    }


    /**
     *收藏：动态、话题、讲坛、视频、专栏、文章时，触发
     * 仅处理【百科的收藏，其他的服务端已处理】
     * 本期不做，分享改版的时候埋
     */
    fun collect(name: String) {
        val properties = JSONObject()
        properties.put("collect_type", formPagePos)
        //百科名称
        properties.put("collect_content", name)
        SensorsDataAPI.sharedInstance().track("Collect", properties)
    }


    /**
     *取消收藏收藏：动态、话题、讲坛、视频、专栏、文章时，触发
     * 仅处理【百科的取消收藏，其他的服务端已处理】
     * 本期不做，分享改版的时候埋
     */
    fun noCollect(name: String) {
        val properties = JSONObject()
        properties.put("no_collect_type", formPagePos)
        //百科名称
        properties.put("no_collect_content", name)
        SensorsDataAPI.sharedInstance().track("NoCollect", properties)
    }

    /**
     *素材库\素材转发
     */
    fun materialShare(name: String, type: String, model: String) {
        val properties = JSONObject()
        properties.put("material_share_name", name)
        properties.put("material_share_type", type)
        properties.put("material_share_mode", model)
        SensorsDataAPI.sharedInstance().track("MaterialLibraryShare", properties)
    }

    /**
     *浏览讲坛详情页面
    forum_class_name	所属讲坛分类	STRING	讲坛分类的名称
    forum_name	讲坛名称	STRING	讲坛的名称
    forum_view_time	讲坛浏览时长	DATETIME	在讲坛页面的停留时长
    forum_video_view_progress	讲坛内视频列表浏览完成度	NUMBER	统计为在屏幕上滑动的距离之和/所有视频列表的深度
     */
    fun browseForum(typeName: String, name: String, browseTime: Long, progress: Double) {
        val properties = JSONObject()
        properties.put("forum_class_name", typeName)
        properties.put("forum_name", name)
        properties.put("forum_view_time", browseTime)
        properties.put("forum_video_view_progress", progress)
        SensorsDataAPI.sharedInstance().track("BrowseForum", properties)
    }

    /**
    浏览讲坛视频页面
    forum_class_name	所属讲坛分类	STRING	讲坛分类的名称
    forum_name	所属讲坛名称	STRING	视频所属讲坛名称
    forum_video_name	讲坛视频名称	STRING	讲坛视频的名称
    forum_video_view_time	讲坛视频页面浏览时长	DATETIME	在讲坛视频页面的停留时长
    video_playback_progress	视频播放进度	NUMBER	统计为讲坛里视频播放的时长/视频的总时长
     */
    fun browseForumVideo(typeName: String, name: String, videoName: String, studySpeed: Long, browseTime: Long) {
        val properties = JSONObject()
        properties.put("forum_class_name", typeName)
        properties.put("forum_name", name)
        properties.put("forum_video_name", videoName)
        properties.put("forum_video_view_time", browseTime)
        properties.put("video_playback_progress", studySpeed)
        SensorsDataAPI.sharedInstance().track("BrowseForumVideo", properties)
    }

    /**
    讲坛详情页目录点击
    forum_name	讲坛名称	STRING	讲坛的名称
    forum_class_name	所属讲坛分类	STRING	讲坛所属的讲坛分类名称
     */
    fun forumVideoListClick(pulName: String, pulTypeName: String) {
        val properties = JSONObject()
        properties.put("forum_name", pulName)
        properties.put("forum_class_name", pulTypeName)
        SensorsDataAPI.sharedInstance().track("ForumVideoListClick", properties)
    }

    //发现、广场、商城搜索
    fun searchTwo(content: String) {
        val properties = JSONObject()
        //发现、广场、商城
        properties.put("search_address", "全局")
        //用户实际输入的内容
        properties.put("search_content", content)
        SensorsDataAPI.sharedInstance().track("SearchTwo", properties)
    }

    //手机消息通知激活
    fun mobileMessageActivation(content: String) {
        var type = ""
        if (content.contains(ActivityRouter.MESSAGE.LIKE_AND_COLLECT)) {
            type = "赞和收藏"
        } else if (content.contains(ActivityRouter.MESSAGE.COMMENT_ME)) {
            type = "评论我的"
        } else if (content.contains("${ActivityRouter.MESSAGE.COMMENT_ME}?index=1")) {
            type = "新增粉丝"
        } else if (content.contains(ActivityRouter.MINE_CENTER.CUSTOMER_SERVICE)) {
            type = "在线客服"
        } else if (content.contains(ActivityRouter.ACTIVITY.ACTIVE_LIVE_INFO)) {
            type = "直播预约"
        } else if (content.contains(ActivityRouter.MESSAGE.SYSTEM_MESSAGE_LIST)) {
            type = "系统消息"
        }
        val properties = JSONObject()
        //赞和收藏、评论我的、新增粉丝、在线客服、好友聊天、直播预约、系统消息
        properties.put("mobilemessageactivation_type", type)
        SensorsDataAPI.sharedInstance().track("MobileMessageActivation", properties)
    }

    /**
    立即解锁讲坛内容
    forum_name	讲坛名称	STRING	讲坛的名称
    forum_class_name	所属讲坛分类	STRING	讲坛所属的讲坛分类名称
    wine_currency_amount	酒币金额	NUMBER	解锁（购买）讲坛所花费的金额
     */
    fun unlockForumContentNow(pulName: String, pulTypeName: String, coinPrice: Long) {
        val properties = JSONObject()
        properties.put("forum_name", pulName)
        properties.put("forum_class_name", pulTypeName)
        properties.put("wine_currency_amount", coinPrice)
        SensorsDataAPI.sharedInstance().track("UnlockForumContentNow", properties)
    }

    /**
    发布动态
    publish_dynamic_location	发布动态位置类型	STRING	首页点击加号发布、在话题页面发布、在关注页面的"分享生活"发布
    dynamic_state_name	动态名称	STRING	动态内容截取一部分字数，暂定前12字
    number_of_pictures	图片数量	NUMBER	统计发布动态时，图片的数量：1~9
    video_duration	视频时长	DATETIME	统计发布动态时，视频的时长
    related_topic_name	关联话题名称	STRING	动态所关联的话题
    location_address_information	定位地址信息	STRING	动态的定位地址信息
     */
    fun releaseDynamic(publishType: String, content: String, pictureCount: Int, videoDuration: Long, relatedTopic: String, location: String) {
        val properties = JSONObject()
        properties.put("publish_dynamic_location", publishType)
        properties.put("dynamic_state_name", content)
        properties.put("number_of_pictures", pictureCount)
        properties.put("video_duration", videoDuration)
        properties.put("related_topic_name", relatedTopic)
        properties.put("location_address_information", location)
        SensorsDataAPI.sharedInstance().track("ReleaseDynamic", properties)
    }

    /**
    发布评论
    remark_position_type	发表评论位置类型	STRING	动态、讲坛视频、专栏文章、百科
    comment_type	评论类型	STRING	评论主内容（动态、讲坛视频、专栏文章、百科）、评论某条评论
    comment_page_type	评论页面类型	STRING	内容详情页（动态、讲坛视频、专栏文章、百科）、快捷评论页（消息列表）
    remark_content	评论内容	STRING
     */
    fun releaseComment(positionType: String, commentType: String, commentPageType: String, remarkContent: String) {
        val properties = JSONObject()
        properties.put("remark_position_type", positionType)
        properties.put("comment_type", commentType)
        properties.put("comment_page_type", commentPageType)
        properties.put("remark_content", remarkContent)
        SensorsDataAPI.sharedInstance().track("ReleaseComment", properties)
    }

    /**
     * 关注/取消关注
    attention_user_name	关注的用户名称	STRING	发起关注的用户其昵称
    attention_user_id	关注的用户id	STRING	发起关注的用户其id
    be_attention_user_name	被 关注的用户名称	STRING	被关注的用户其昵称
    be_attention_user_id	被 关注的用户id	STRING	被关注的用户其id
    attention_page_type	关注页面类型	STRING	动态详情页、个人主页、我的关注页、我的粉丝页、我的好友页
    @param boolean = true 关注 false = 取消关注
     */
    fun attention(userName: String, userId: String, beUserName: String, beUserId: String, attentionType: String, boolean: Boolean) {
        val properties = JSONObject()
        properties.put(if (boolean) "attention_user_name" else "no_attention_user_name", userName)
        properties.put(if (boolean) "attention_user_id" else "no_attention_user_id", userId)
        properties.put(if (boolean) "be_attention_user_name" else "no_be_attention_user_name", beUserName)
        properties.put(if (boolean) "be_attention_user_id" else "no_be_attention_user_id", beUserId)
        properties.put(if (boolean) "attention_page_type" else "no_attention_page_type", attentionType)
        SensorsDataAPI.sharedInstance().track(if (boolean) "Attention" else "NoAttention", properties)
    }

    fun onCreateTime() {
        mCreateTimeMillis = System.currentTimeMillis()
    }


    fun onDestroyTime() {
        mDestroyTimeMillis = System.currentTimeMillis()
    }


    fun getBrowseTime(): Long {
        return try {
            mDestroyTimeMillis = System.currentTimeMillis()
            (mDestroyTimeMillis - mCreateTimeMillis) / 1000
        } catch (num: NumberFormatException) {
            //防止意外情况
            0
        }
    }

    //设置页面来源：动态、话题、讲坛分类、讲坛、视频、专栏、文章、百科
    fun setFormPagePos(pageName: String) {
        formPagePos = pageName
    }

    //设置分享方式：微信好友、朋友圈、分享海报
    fun setShareWay(wayName: String) {
        shareWay = wayName
    }

    //设置发现、广场、商城
    fun setHomePagePos(pos: String) {
        homePagePos = pos
    }

    //微信、朋友圈、保存到相册
    private var shareStyle = ""
    fun setShareStyle(shareStyle: String) {
        this.shareStyle = shareStyle
    }
    //--------------------------酒窖优化埋点 start-------------------------------

    //设置  附近酒窖列表、全屏大地图、搜索结果页
    fun setWineryPagePos(pos: String) {
        wineryPagePos = pos
    }

    //设置  酒窖详情页、全部评价页
    fun setWineryCommentPagePos(pos: String) {
        wineryCommentPagePos = pos
    }

    //设置  酒窖详情页、用户主页、社区发现页
    fun setWineryDynamicPagePos(pos: String) {
        wineryDynamicPagePos = pos
    }

    //设置  酒窖详情页、全部评价页
    fun setWineryName(name: String) {
        wineryName = name
    }

    //选中酒窖时候
    fun nearbyCellarDisplay(nearby_cellar_displaypage: String, nearby_cellar_displayregion: String, cellar_name: String) {
        val properties = JSONObject()
        // nearby_cellar_displaypage	曝光页面  附近酒窖列表、全屏大地图
        // nearby_cellar_displayregion	所属大区  东北、华东、华北、华中、华南、西南、西北
        // cellar_name	酒窖名称
        properties.put("nearby_cellar_displaypage", nearby_cellar_displaypage)
        properties.put("nearby_cellar_displayregion", nearby_cellar_displayregion)
        properties.put("cellar_name", cellar_name)
        SensorsDataAPI.sharedInstance().track("NearbyCellarDisplay", properties)
    }

    //浏览页面时候触发
    fun nearbyCellarBrowse(nearby_cellar_browsepage: String) {
        val properties = JSONObject()
        // nearby_cellar_browsepage	页面名称 附近酒窖列表（小地图）、附近酒窖列表（全屏地图）
        // nearby_cellar_browstime	页面浏览时长
        properties.put("nearby_cellar_browsepage", nearby_cellar_browsepage)
        properties.put("nearby_cellar_browstime", getBrowseTime())
        SensorsDataAPI.sharedInstance().track("NearbyCellarBrowse", properties)
    }

    //酒窖详情页浏览
    fun cellarDetailsBrowse(cellar_name: String) {
        val properties = JSONObject()
        //  cellar_details_intopage	发起位置  附近酒窖列表、全屏大地图、搜索结果页
        //  cellar_details_browstime	平均访问时长
        properties.put("cellar_name", cellar_name)
        properties.put("cellar_details_intopage", wineryPagePos)
        properties.put("cellar_details_browstime", getBrowseTime())
        SensorsDataAPI.sharedInstance().track("CellarDetailsBrowse", properties)
    }

    //点击banner时触发
    fun nearbyCellarBanner(nearby_cellar_bannername: String) {
        val properties = JSONObject()
        properties.put("nearby_cellar_bannername", nearby_cellar_bannername)
        SensorsDataAPI.sharedInstance().track("NearbyCellarBanner", properties)
    }

    //酒窖详情-基本元素点击
    fun cellarDetailsElement(cellar_name: String, cellar_details_element: String) {
        val properties = JSONObject()
        properties.put("cellar_name", cellar_name)
        properties.put("cellar_details_element", cellar_details_element)
        SensorsDataAPI.sharedInstance().track("CellarDetailsElement", properties)
    }

    //酒窖私房下酒菜查看
    fun cellarFoodSee(cellar_name: String, cellar_food_foodname: String) {
        val properties = JSONObject()
        properties.put("cellar_name", cellar_name)
        properties.put("cellar_food_foodname", cellar_food_foodname)
        SensorsDataAPI.sharedInstance().track("CellarFoodSee", properties)
    }

    //酒窖评价查看
    fun cellarCommentSee(cellar_comment_content: String) {
        val properties = JSONObject()
        //酒窖名称
        //发起页面 :酒窖详情页、全部评价页
        //评论内容
        properties.put("cellar_name", wineryName)
        properties.put("cellar_comment_intopage", wineryCommentPagePos)
        properties.put("cellar_comment_content", cellar_comment_content)
        SensorsDataAPI.sharedInstance().track("CellarCommentSee", properties)
    }

    //酒窖动态查看
    fun cellarDynamicSee(wineryName: String) {
        val properties = JSONObject()
        properties.put("cellar_name", wineryName)
        //酒窖详情页、用户主页、社区发现页
        properties.put("cellar_dynamic_seepage", wineryDynamicPagePos)
        properties.put("cellar_dynamic_browstime", getBrowseTime())
        SensorsDataAPI.sharedInstance().track("CellarDynamicSee", properties)
    }

    //模式切换 点击“进入”按钮时触发
    fun modeSwitching(mode_switching_type: String) {
        val properties = JSONObject()
        //进入经营者模式，进入社区模式
        properties.put("mode_switching_type", mode_switching_type)
        SensorsDataAPI.sharedInstance().track("ModeSwitching", properties)
    }

    //经营者中心页面浏览
    fun operatorCenterBrowse(cellar_name: String) {
        val properties = JSONObject()
        properties.put("cellar_name", cellar_name)
        properties.put("operator_center_time", getBrowseTime())
        SensorsDataAPI.sharedInstance().track("OperatorCenterBrowse", properties)
    }

    //创建/编辑线上酒窖 线上酒窖编辑页，成功提交时触发
    fun operatorCreateCellar(cellar_name: String, operator_createcellar_type: String) {
        val properties = JSONObject()
        properties.put("cellar_name", cellar_name)
        //创建酒窖提审、编辑酒窖提审
        properties.put("operator_createcellar_type", operator_createcellar_type)
        properties.put("operator_createcellar_time", getBrowseTime())
        SensorsDataAPI.sharedInstance().track("OperatorCreateCellar", properties)
    }

    //线上酒窖退出保存 线上酒窖编辑页，填写信息后，未提交审核，退出当前页面
    fun operatorCellarOut(cellar_name: String) {
        val properties = JSONObject()
        properties.put("cellar_name", cellar_name)
        SensorsDataAPI.sharedInstance().track("OperatorCellarOut", properties)
    }

    //创建酒窖私房下酒菜 酒窖下酒菜创建成功时触发
    fun operatorCreateFood(cellar_name: String) {
        val properties = JSONObject()
        properties.put("cellar_name", cellar_name)
        SensorsDataAPI.sharedInstance().track("OperatorCreateFood", properties)
    }

    //创建酒窖评论 酒窖评论创建成功时触发
    fun operatorCreateComment(cellar_name: String) {
        val properties = JSONObject()
        properties.put("cellar_name", cellar_name)
        SensorsDataAPI.sharedInstance().track("OperatorCreateComment", properties)
    }

    //创建酒窖动态 酒窖动态创建成功时触发
    fun operatorCreateDynamic(operator_createdynamic_type: String) {
        val properties = JSONObject()
        properties.put("cellar_name", wineryName)
        properties.put("operator_createdynamic_type", operator_createdynamic_type)
        SensorsDataAPI.sharedInstance().track("OperatorCreateDynamic", properties)
    }

    /**
     * @param drink_food_plate_name 浏览板块
     * @param class_name 所属分类
     * @param recommend_name 所属推荐
     * @param drink_food_name 菜谱名称
     * @param drink_food_view_time 菜谱浏览时长
     */
    fun browseDrinkFood(drink_food_plate_name: String, class_name: String, recommend_name: String, drink_food_name: String, drink_food_view_time: Long) {
        val properties = JSONObject()
        properties.put("drink_food_plate_name", drink_food_plate_name)
        properties.put("class_name", class_name)
        properties.put("recommend_name", recommend_name)
        properties.put("drink_food_name", drink_food_name)
        properties.put("drink_food_view_time", drink_food_view_time)
        SensorsDataAPI.sharedInstance().track("BrowseDrinkFood", properties)
    }
    //--------------------------酒窖优化埋点 end-------------------------------
    //--------------------------新零售埋点 start-----------------------------


    //提交售后申请时触发
    fun refundApply(order_id: String, product_store_name: String, product_id: String, product_name: String, product_class: String, product_specifications: String, product_price: String, refund_reason: String, refund_apply_amount: String) {
        val properties = JSONObject()
        /*order_id	订单ID
        *product_store_name	店铺名称
        *product_id	商品ID
        *product_name	商品名称
        *product_class	商品分类
        *product_price	商品价格
        *product_specifications	商品规格
        *product_price	商品价格
        *refund_reason	售后申请退款原因
        *refund_apply_amount	售后申请退款金额
        * */
        properties.put("order_id", order_id)
        properties.put("product_store_name", product_store_name)
        properties.put("product_id", product_id)
        properties.put("product_name", product_name)
        properties.put("product_class", product_class)
        properties.put("product_specifications", product_specifications)
        properties.put("product_price", product_price)
        properties.put("refund_reason", refund_reason)
        properties.put("refund_apply_amount", refund_apply_amount)
        SensorsDataAPI.sharedInstance().track("RefundApply", properties)
    }


    //经营者中心元素点击  线上酒窖、下酒菜、酒窖评价、酒窖动态、我的商品、销售订单、售后列表、公文政策、素材库
    fun operatorCenter(operator_center_button: String) {
        val properties = JSONObject()
        properties.put("operator_center_button", operator_center_button)
        SensorsDataAPI.sharedInstance().track("OperatorCenter", properties)
    }

    //售后申请页浏览
    fun refundApplySee() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("RefundApplySee", properties)
    }

    //查看物流详情
    fun logisticsDetails() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("LogisticsDetails", properties)
    }

    //购物车页浏览   商品详情页、商城页
    fun shopCartSee(cart_details_Jump: String) {
        val properties = JSONObject()
        properties.put("cart_details_Jump", cart_details_Jump)
        SensorsDataAPI.sharedInstance().track("ShopCartSee", properties)
    }

    //商城页广告点击   推荐广告、优选广告
    fun shopAdClick(shop_ad_name: String, shop_ad_type: String) {
        val properties = JSONObject()
        properties.put("shop_ad_name", shop_ad_name)
        properties.put("shop_ad_type", shop_ad_type)
        SensorsDataAPI.sharedInstance().track("ShopAdClick", properties)
    }

    //商城金刚区点击
    fun shopJingangClick(shop_jingang_click: String) {
        val properties = JSONObject()
        properties.put("shop_jingang_click", shop_jingang_click)
        SensorsDataAPI.sharedInstance().track("ShopJingangClick", properties)
    }

    //商城页banner点击
    fun shopBannerClick() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("ShopBannerClick", properties)
    }

    //商城页浏览
    fun shopVisit() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("ShopVisit", properties)
    }

    //商品详情页浏览 : 酒窖详情页、商城首页、新人专享页、商品内容页、商品详情页推荐专区、支付成功页猜你喜欢、购物车页猜你喜欢、订单页猜你喜欢、订单详情、其他
    fun productVisit(product_details_Jump: String, product_id: String, product_store_name: String, product_name: String, product_class: String, product_price: String) {
        val properties = JSONObject()
        properties.put("product_details_Jump", product_details_Jump)
        properties.put("product_id", product_id)
        properties.put("product_store_name", product_store_name)
        properties.put("product_name", product_name)
        properties.put("product_class", product_class)
        properties.put("product_price", product_price)
        SensorsDataAPI.sharedInstance().track("ProductVisit", properties)
    }

    //商品分享
    fun productSharing(product_id: String, product_store_name: String, product_name: String, product_class: String, product_price: String) {
        val properties = JSONObject()
        properties.put("product_id", product_id)
        properties.put("product_store_name", product_store_name)
        properties.put("product_name", product_name)
        properties.put("product_class", product_class)
        properties.put("product_price", product_price)
        properties.put("product_sharing", shareStyle)
        SensorsDataAPI.sharedInstance().track("ProductSharing", properties)
    }

    //商品详情轮播图点击
    fun productCarousel(product_carousel_type: String, product_name: String) {
        val properties = JSONObject()
        properties.put("product_carousel_type", product_carousel_type)
        properties.put("product_name", product_name)
        SensorsDataAPI.sharedInstance().track("ProductCarousel", properties)
    }


    //商品详情种草秀点击
    fun productShow(product_id: String, product_store_name: String, product_name: String, dynamic_id: String, dynamic_name: String, dynamic_class: String) {
        val properties = JSONObject()
        properties.put("product_id", product_id)
        properties.put("product_store_name", product_store_name)
        properties.put("product_name", product_name)
        properties.put("dynamic_id", dynamic_id)
        properties.put("dynamic_name", dynamic_name)
        properties.put("dynamic_class", dynamic_class)
        SensorsDataAPI.sharedInstance().track("ProductShow", properties)
    }

    //商品详情评测视频点击
    fun pcvideoClick(product_id: String, product_store_name: String, product_name: String, pcvideo_id: String, pcvideo_name: String) {
        val properties = JSONObject()
        properties.put("product_id", product_id)
        properties.put("product_store_name", product_store_name)
        properties.put("product_name", product_name)
        properties.put("pcvideo_id", pcvideo_id)
        properties.put("pcvideo_name", pcvideo_name)
        SensorsDataAPI.sharedInstance().track("PcvideoClick", properties)
    }

    //商品详情评价图片点击
    fun productEvaluateClick(product_id: String, product_store_name: String, product_name: String, product_specifications: String, product_evaluate_id: Long) {
        val properties = JSONObject()
        properties.put("product_id", product_id)
        properties.put("product_store_name", product_store_name)
        properties.put("product_name", product_name)
        properties.put("product_specifications", product_specifications)
        properties.put("product_evaluate_id", product_evaluate_id)
        SensorsDataAPI.sharedInstance().track("ProductEvaluateClick", properties)
    }

    //商品详情待支付弹框去支付
    fun productDetailPayment(order_id: String, product_id: List<Int>, product_store_name: String, product_name: List<String>, product_specifications: List<String>) {
        val properties = JSONObject()
        properties.put("order_id", order_id)
        properties.put("product_id", product_id)
        properties.put("product_store_name", product_store_name)
        properties.put("product_name", product_name)
        properties.put("product_specifications", product_specifications)
        SensorsDataAPI.sharedInstance().track("ProductDetailPayment", properties)
    }

    //商品详情页立即购买
    fun productBuy(product_id: String, product_store_name: String, product_name: String, product_specifications: String, product_price: String, product_quantity: Int, if_seckill_products: String, seckill_id: String, seckill_name: String) {
        val properties = JSONObject()
        properties.put("product_id", product_id)
        properties.put("product_store_name", product_store_name)
        properties.put("product_name", product_name)
        properties.put("product_specifications", product_specifications)
        properties.put("product_price", product_price)
        properties.put("product_quantity", product_quantity)
        properties.put("if_seckill_products", if_seckill_products)
        properties.put("seckill_id", seckill_id)
        properties.put("seckill_name", seckill_name)
        SensorsDataAPI.sharedInstance().track("ProductBuy", properties)
    }

    //发布评价页预览
    fun productEvaluateSee() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("ProductEvaluateSee", properties)
    }

    //--------------------------新零售埋点 end-------------------------------

    //入库统计-列表页预览   渠道员工、管理员
    fun applicationSee(application_user_type: String) {
        val properties = JSONObject()
        properties.put("application_user_type", application_user_type)
        SensorsDataAPI.sharedInstance().track("ApplicationSee", properties)
    }


    //入库统计-入库申请页预览
    fun applicationAddSee() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("ApplicationAddSee", properties)
    }

    //入库统计-申请领用页预览
    fun applicationUseSee() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("ApplicationUseSee", properties)
    }

    //活动埋点
    fun bagShare(invite_activity_name: String, bag_name: String, bag_share_type: String, bag_share_mode: String, bag_share_time: Long) {
        val properties = JSONObject()
        properties.put("invite_activity_name", invite_activity_name)
        properties.put("bag_name", bag_name)
        properties.put("bag_share_type", bag_share_type)
        properties.put("bag_share_mode", bag_share_mode)
        properties.put("bag_share_time", bag_share_time)
        SensorsDataAPI.sharedInstance().track("BagShare", properties)
    }

    /*---------------------------------------------秒杀相关埋点-----------------------------------------------------*/
    /**秒杀商品点击
     * @author: merbng
     * @time: 2023/3/27 16:23
     * @description: 发起页面
     * 秒杀活动ID
     * 秒杀活动名称
     * 秒杀活动状态
     * 商品ID
     * 商品名称
     * 店铺名称
     */
    fun seckillGoodsClick(seckill_goods_view: String, seckill_id: String, seckill_name: String, seckill_status: String, product_id: String, product_name: String, product_store_name: String) {
        val properties = JSONObject()
        properties.put("seckill_goods_view", seckill_goods_view)
        properties.put("seckill_id", seckill_id)
        properties.put("seckill_name", seckill_name)
        properties.put("seckill_status", seckill_status)
        properties.put("product_id", product_id)
        properties.put("product_name", product_name)
        properties.put("product_store_name", product_store_name)
        SensorsDataAPI.sharedInstance().track("SeckillGoodsClick", properties)
    }

    //酒窖全部秒杀页浏览
    fun cellarSeckillPageView() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("CellarSeckillPageView", properties)
    }

    //平台秒杀专题页浏览
    fun seckillPageView() {
        try {
            val properties = JSONObject()
            properties.put("memberpage_view_time", getBrowseTime())
            SensorsDataAPI.sharedInstance().track("SeckillPageView", properties)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
    }

    //平台秒杀专题页分类点击
    fun seckillClassifyClick(seckill_classify_name: String) {
        val properties = JSONObject()
        properties.put("seckill_classify_name", seckill_classify_name)
        SensorsDataAPI.sharedInstance().track("SeckillClassifyClick", properties)
    }

    //首页Banner点击
    fun homeBannerClick(homebanner_name: String) {
        val properties = JSONObject()
        properties.put("homebanner_name", homebanner_name)
        SensorsDataAPI.sharedInstance().track("HomeBannerClick", properties)
    }

    //消息ICON点击
    fun newsiconClick(newsicon_position: String) {
        val properties = JSONObject()
        properties.put("newsicon_position", newsicon_position)
        SensorsDataAPI.sharedInstance().track("NewsIconClick", properties)
    }

    //首页重点业务点击
    fun homeKeyClick(homekey_name: String) {
        val properties = JSONObject()
        properties.put("homekey_name", homekey_name)
        SensorsDataAPI.sharedInstance().track("HomeKeyClick", properties)
    }

    //首页金刚区点击
    fun homeJingangClick(homejingang_name: String) {
        val properties = JSONObject()
        properties.put("homejingang_name", homejingang_name)
        SensorsDataAPI.sharedInstance().track("HomeJingangClick", properties)
    }

    //首页长期活动点击
    fun homeChangqiClick(homechangqi_name: String) {
        val properties = JSONObject()
        properties.put("homechangqi_name", homechangqi_name)
        SensorsDataAPI.sharedInstance().track("HomeChangqiClick", properties)
    }

    //首页动态置顶广告点击
    fun homeZhidingClick(homezhiding_name: String) {
        val properties = JSONObject()
        properties.put("homezhiding_name", homezhiding_name)
        SensorsDataAPI.sharedInstance().track("HomeZhidingClick", properties)
    }

    //分类话题页浏览
    fun classifyTalkView() {
        SensorsDataAPI.sharedInstance().track("ClassifyTalkView")
    }

    //分类话题页banner点击
    fun classifyTopicBannerClick(classifytopicbanne_name: String) {
        val properties = JSONObject()
        properties.put("classifytopicbanne_name", classifytopicbanne_name)
        SensorsDataAPI.sharedInstance().track("ClassifyTopicBannerClick", properties)
    }

    //分类话题页话题点击
    fun classifyTopicClick(classifytopic_id: String, classifytopic_name: String, topic_id: String, topic_name: String) {
        val properties = JSONObject()
        properties.put("classifytopic_id", classifytopic_id)
        properties.put("classifytopic_name", classifytopic_name)
        properties.put("topic_id", topic_id)
        properties.put("topic_name", topic_name)
        SensorsDataAPI.sharedInstance().track("ClassifyTopicClick", properties)
    }
    // 搜索热词直接搜素
    fun hotWordsSearch(hotwords_position: String,hotwords_name: String) {
        val properties = JSONObject()
        properties.put("hotwords_position", hotwords_position)
        properties.put("hotwords_name", hotwords_name)
        SensorsDataAPI.sharedInstance().track("HotWordsSearch", properties)
    }

    // 下酒菜首页浏览
    fun xfoodView() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("XfoodView", properties)
    }

    // 讲坛列表页浏览
    fun teachView() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("TeachView", properties)
    }

    // 讲坛查看
    fun forumClick(forum_id: String,forum_name: String) {
        val properties = JSONObject()
        properties.put("forum_id", forum_id)
        properties.put("forum_name", forum_name)
        SensorsDataAPI.sharedInstance().track("ForumClick", properties)
    }

    // 百科页列表浏览
    fun wikiView() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("WikiView", properties)
    }

    // 百科查看
    fun wikiClick(wiki_id: String,wiki_name: String) {
        val properties = JSONObject()
        properties.put("wiki_id", wiki_id)
        properties.put("wiki_name", wiki_name)
        SensorsDataAPI.sharedInstance().track("WikiClick", properties)
    }


    // 专栏列表页浏览
    fun articleView() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("ArticleView", properties)
    }

    // 专栏查看
    fun articleClick(special_column_id: String,special_column_name: String) {
        val properties = JSONObject()
        properties.put("special_column_id", special_column_id)
        properties.put("special_column_name", special_column_name)
        SensorsDataAPI.sharedInstance().track("ArticleClick", properties)
    }


    // 选择话题页浏览
    fun publishTrendsTalkView() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("PublishTrendsTalkView", properties)
    }


    // 全部话题页预览
    fun allTalkView() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("AllTalkView", properties)
    }


    // 个人中心banner点击
    fun meBannerClick(mebanner_name:String) {
        val properties = JSONObject()
        properties.put("mebanner_name", mebanner_name)
        SensorsDataAPI.sharedInstance().track("MeBannerClick", properties)
    }


    // 附近酒窖banner点击
    fun wineBannerClick(winebanner_name:String) {
        val properties = JSONObject()
        properties.put("winebanner_name", winebanner_name)
        SensorsDataAPI.sharedInstance().track("WineBannerClick", properties)
    }


    // 商城banner点击
    fun shopBannerClick(shopbanner_name:String) {
        val properties = JSONObject()
        properties.put("shopbanner_name", shopbanner_name)
        SensorsDataAPI.sharedInstance().track("ShopBannerClick", properties)
    }


    // 社区视频页浏览
    fun communityVideoView() {
        val properties = JSONObject()
        SensorsDataAPI.sharedInstance().track("CommunityVideoView", properties)
    }

}
